#!/usr/bin/python
#-*- coding: utf-8 -*-

import MySQLdb as mdb
import sys

con = mdb.connect("localhost","root", "root", "test")

with con:
    cur = con.cursor()
    #cur.execute("INSERT INTO student(name, `from`, title) VALUES('ADF','ASF','ASF')")
    #cur.execute("INSERT INTO student(name, `from`, title) VALUES('123DF','A123SF','32ASF')")
    cur.execute("SELECT * FROM student")
    numrows = int(cur.rowcount)
    for i in range(numrows):
        row = cur.fetchone()
        print row[0], row[1], row[2], row[3]

redis = redis.Redis(host='127.0.0.1',  port=6379)
time_now =  time.time()
print time_now
while True:
    now = time.strftime("%Y/%m/%d %H:%M:%S",  time.localtime())
    redis.rpush('test_e', now)
    time.sleep(1)
    if int(time_now)+60 > int(time.time()):
        break    
    
